package com.gao.api.gate.quick.endpoint;

import com.gao.api.gate.quick.A;
import io.netty.channel.ChannelOption;
import io.netty.channel.group.ChannelGroup;
import io.netty.handler.logging.LoggingHandler;
import io.netty.util.AttributeKey;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * <p></p>
 *
 * @author gaoshuangwen
 * @since 2022/01/23 15:51
 */
public interface Endpoint<E extends Endpoint<E, C>, C extends EndpointConfig> {
    default  <V> E attr(AttributeKey<V> key, V value) {
        Objects.requireNonNull(key, "key");
        Objects.requireNonNull(value, "value");
        self().configuration().attributes =EndpointConfig.updateMap(configuration().attributes, key, value);
        return self();
    }
    default <V> E option(ChannelOption<V> key, V value) {
        Objects.requireNonNull(key, "key");
        Objects.requireNonNull(value, "value");
        self().configuration().options =EndpointConfig.updateMap(configuration().options, key, value);
        return self();
    }
    default E channelGroup(ChannelGroup channelGroup) {
        Objects.requireNonNull(channelGroup, "channelGroup");
        self().configuration().channelGroup =channelGroup;
        return self();
    }
    default E loggingHandler(LoggingHandler loggingHandler) {
        Objects.requireNonNull(loggingHandler, "loggingHandler");
        self().configuration().loggingHandler =loggingHandler;
        return self();
    }
    default E ioLoopGroupConfig(LoopGroupConfig ioLoopGroupConfig) {
        Objects.requireNonNull(ioLoopGroupConfig, "ioLoopGroupConfig");
        self().configuration().ioLoopGroupConfig =ioLoopGroupConfig;
        return self();
    }
    C configuration();
    E self();

}
